home *** CD-ROM | disk | FTP | other *** search
/ .net (French) 1996 November / .net Magazine (FR) - Issue 01 - Nov 1996.iso / mac / Butineur / Netscape Plug-ins / KM's QuickTime plug / Sources / pascal_npapi.h < prev    next >
Text File  |  1996-01-31  |  7KB  |  260 lines

  1. // pascal_npmac.cpp  My personal translation of Netscape's npapi.h file from the New SDK 0.7.
  2. // Interface bugs are probably mine, not Netscape's.
  3. // Kevin McMurtrie  mcmurtri@wco.com
  4. // 1/31/95
  5.  
  6.  
  7. /*
  8.  *  npapi.h $Revision: 1.56 $
  9.  *  Netscape client plug-in API spec
  10.  */
  11.  
  12. #ifndef _NPAPI_H_
  13. #define _NPAPI_H_
  14.  
  15.  
  16. /* XXX this needs to get out of here */
  17. #if defined(__MWERKS__)
  18. #ifndef XP_MAC
  19. #define XP_MAC
  20. #endif
  21. #endif
  22.  
  23.  
  24. /*
  25.  *  Version constants
  26.  */
  27.  
  28. #define NP_VERSION_MAJOR 0
  29. #define NP_VERSION_MINOR 6
  30.  
  31.  
  32.  
  33. /* 
  34.  *  Basic types
  35.  */
  36.  
  37. #ifndef _UINT16
  38. typedef unsigned short uint16;
  39. #endif
  40. #ifndef _UINT32
  41. typedef unsigned long uint32;
  42. #endif
  43. #ifndef _INT16
  44. typedef short int16;
  45. #endif
  46. #ifndef _INT32
  47. typedef long int32;
  48. #endif
  49.  
  50. #ifndef FALSE
  51. #define FALSE (0)
  52. #endif
  53. #ifndef TRUE
  54. #define TRUE (1)
  55. #endif
  56. #ifndef NULL
  57. #define NULL (0L)
  58. #endif
  59.  
  60. typedef unsigned char   NPBool;
  61. typedef void*           NPEvent;
  62. typedef int16           NPError;
  63. typedef char*           NPMIMEType;
  64.  
  65.  
  66. /*
  67.  *  NPP is a plug-in's opaque instance handle
  68.  */
  69. typedef struct _NPP
  70. {
  71.     void*   pdata;                /* plug-in private data */
  72.     void*   ndata;                /* netscape private data */
  73. } NPP_t;
  74.  
  75. typedef NPP_t*  NPP;
  76.  
  77.  
  78.  
  79. typedef struct _NPStream
  80. {
  81.     void*       pdata;                /* plug-in private data */
  82.     void*       ndata;                /* netscape private data */
  83.     const char* url;
  84.     uint32      end;
  85.     uint32      lastmodified;
  86. } NPStream;
  87.  
  88. typedef struct _NPByteRange
  89. {
  90.     int32                   offset;                /* negative offset means from the end */
  91.     uint32                  length;
  92.     struct _NPByteRange*    next;
  93. } NPByteRange;
  94.  
  95.  
  96. typedef struct _NPSavedData
  97. {
  98.     int32   len;
  99.     void*   buf;
  100. } NPSavedData;
  101.  
  102.  
  103.  
  104. typedef struct _NPRect
  105. {
  106.     uint16  top;
  107.     uint16  left;
  108.     uint16  bottom;
  109.     uint16  right;
  110. } NPRect;
  111.  
  112. typedef struct _NPWindow 
  113. {
  114.     void*   window;                 /* platform specific window handle */
  115.     uint32  x;                      /* position of top left corner relative to a netscape page */
  116.     uint32  y;                   
  117.     uint32  width;                  /* maximum window size */
  118.     uint32  height;
  119.     NPRect  clipRect;               /* clipping rectangle in port coordinates */
  120. } NPWindow;
  121.  
  122.  
  123.  
  124. typedef struct _NPFullPrint
  125. {
  126.     NPBool      pluginPrinted;      /* Set TRUE if plugin handled fullscreen printing */
  127.     NPBool      printOne;           /* TRUE if plugin should print one copy to default printer */
  128.     void*       platformPrint;      /* Platform-specific printing info */
  129. } NPFullPrint;
  130.  
  131. typedef struct _NPEmbedPrint
  132. {
  133.     NPWindow    window;
  134.     void*       platformPrint;      /* Platform-specific printing info */
  135. } NPEmbedPrint;
  136.  
  137. typedef struct _NPPrint
  138. {
  139.     uint16              mode;       /* NP_FULL or NP_EMBED */
  140.     union
  141.     {
  142.         NPFullPrint     fullPrint;  /* if mode is NP_FULL */
  143.         NPEmbedPrint    embedPrint; /* if mode is NP_EMBED */
  144.     } print;
  145. } NPPrint;
  146.  
  147.  
  148.  
  149.  
  150. #ifdef XP_MAC
  151.  
  152. /*
  153.  *  Mac-specific structures and definitions.
  154.  */
  155.  
  156. #include <Quickdraw.h>
  157. #include <Events.h>
  158.  
  159. typedef struct NP_Port
  160. {
  161.     CGrafPtr    port;           /* Grafport */
  162.     int32       portx;          /* position inside the topmost window */
  163.     int32       porty;
  164. } NP_Port;
  165.  
  166. /*
  167.  *  Non-standard event types that can be passed to HandleEvent
  168.  */
  169. #define getFocusEvent       (osEvt + 16)
  170. #define loseFocusEvent      (osEvt + 17)
  171. #define adjustCursorEvent   (osEvt + 18)
  172.  
  173. #endif /* XP_MAC */
  174.  
  175.  
  176.  
  177.  
  178. #define NP_EMBED        1
  179. #define NP_FULL         2
  180. #define NP_BACKGROUND   3
  181.  
  182. #define NP_NORMAL       1
  183. #define NP_SEEK         2
  184. #define NP_ASFILE       3
  185.  
  186. #define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
  187.  
  188.  
  189. /*
  190.  *  Error and reason code definitions.
  191.  */
  192.  
  193. #define NP_NOERR  0
  194. #define NP_EINVAL 1
  195. #define NP_EABORT 2
  196.  
  197. #define NPERR_BASE                      0
  198. #define NPERR_NO_ERROR                  (NPERR_BASE + 0)
  199. #define NPERR_GENERIC_ERROR             (NPERR_BASE + 1)
  200. #define NPERR_INVALID_INSTANCE_ERROR    (NPERR_BASE + 2)
  201. #define NPERR_INVALID_FUNCTABLE_ERROR   (NPERR_BASE + 3)
  202. #define NPERR_MODULE_LOAD_FAILED_ERROR  (NPERR_BASE + 4)
  203. #define NPERR_OUT_OF_MEMORY_ERROR       (NPERR_BASE + 5)
  204. #define NPERR_INVALID_PLUGIN_ERROR      (NPERR_BASE + 6)
  205. #define NPERR_INVALID_PLUGIN_DIR_ERROR  (NPERR_BASE + 7)
  206. #define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
  207.  
  208. #define NPRES_BASE                      0
  209. #define NPRES_NETWORK_ERR               (NPRES_BASE + 0)
  210. #define NPRES_USER_BREAK                (NPRES_BASE + 1)
  211. #define NPRES_DONE                      (NPRES_BASE + 3)
  212.  
  213.  
  214.  
  215. /*
  216.  *  Function prototypes.
  217.  *  Functions beginning with 'NPP' are functions provided by the plugin that Netscape will call.
  218.  *  Functions beginning with 'NPN' are functions provided by Netscape that the plugin will call.
  219.  */
  220.  
  221.  
  222. #ifdef __cplusplus
  223. extern "C" {
  224. #endif
  225.  
  226. extern pascal NPError    NPP_Initialize(void);
  227. extern pascal void        NPP_Shutdown(void);
  228. extern pascal NPError    NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
  229. extern pascal NPError    NPP_Destroy(NPP instance, NPSavedData** save);
  230. extern pascal NPError    NPP_SetWindow(NPP instance, NPWindow* window);
  231. extern pascal NPError    NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
  232. extern pascal NPError    NPP_DestroyStream(NPP instance, NPStream* stream, NPError reason);
  233. extern pascal int32        NPP_WriteReady(NPP instance, NPStream* stream);
  234. extern pascal int32        NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
  235. extern pascal void        NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
  236. extern pascal void        NPP_Print(NPP instance, NPPrint* platformPrint);
  237. extern pascal int16    NPP_HandleEvent(NPP instance, void* event);
  238.  
  239. void        NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor);
  240. NPError     NPN_GetURL(NPP instance, const char* url, const char* window);
  241. NPError     NPN_PostURL(NPP instance, const char* url, uint32 len, const char* buf, NPBool file);
  242. NPError     NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
  243. NPError     NPN_NewStream(NPP instance, NPMIMEType type, NPStream* stream);
  244. int32       NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
  245. NPError     NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason);
  246. void        NPN_Status(NPP instance, const char* message);
  247. const char* NPN_UserAgent(NPP instance);
  248. void*       NPN_MemAlloc(uint32 size);
  249. void        NPN_MemFree(void* ptr);
  250. uint32      NPN_MemFlush(uint32 size);
  251. void        NPN_ReloadPlugins(NPBool reloadPages);
  252.  
  253. #ifdef __cplusplus
  254. }  /* end extern "C" */
  255. #endif
  256.  
  257.  
  258. #endif /* _NPAPI_H_ */
  259.  
  260.